{__NOLAYOUT__}
<!DOCTYPE html>
<!--[if lt IE 7 ]> <html lang="en" class="no-js ie6 lt8"> <![endif]-->
<!--[if IE 7 ]>    <html lang="en" class="no-js ie7 lt8"> <![endif]-->
<!--[if IE 8 ]>    <html lang="en" class="no-js ie8 lt8"> <![endif]-->
<!--[if IE 9 ]>    <html lang="en" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
    <head>
        <meta charset="UTF-8" />
        <title>{$Think.lang.LOGINWEB}</title>
        <link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/css/style.css" />
        <script src="__PUBLIC__/Lib/jquery/js/jquery-1.8.3.js"></script>
    </head>
    <body>
        <div class="container">
            <section>				
                <div id="container_demo" >
                    <div id="wrapper">
                        <div id="doUrl" callback_url="{$callback_url}" style="display: none;"></div>
                        <div id="login" class="animate form">
                            <form  action="{:U('Admin/User/doLogin')}" autocomplete="off" id="lgin" method="post"> 
                                <h1>管理登录</h1> 
                                <p> 
                                    <label for="username" class="uname" data-icon="u" >{$Think.lang.USERNAME}</label>
                                    <input id="username" name="username" required="required" type="text" value="" autocomplete="off" placeholder="请输入用户名"/>
                                </p>
                                <p> 
                                    <label for="password" class="youpasswd" data-icon="p">{$Think.lang.PASSWORD}</label>
                                    <input id="password" name="passwd" required="required" type="password" value="" placeholder="请输入密码" /> 
                                </p>
                                <if condition="$code.BALOGIN eq '1'">
                                <p> 
                                    <label for="password" class="youpasswd" data-icon="p">{$Think.lang.CODE}</label><br/>
                                    <input id="code" name="code" required="required" type="type" value="" placeholder="请输入验证码" autocomplete="off" style="width: 67%;"/> 
                                    <img id="verify" src="{:U('Admin/User/verify')}" class="changeVerify" style="cursor: pointer;position: relative;top: 3px;float: right" title="{$Think.lang.CLICKUPDATECODE}" />
                                </p>
                                </if>
<!--                                <p class="keeplogin"> 
									<input type="checkbox" name="loginkeeping" id="loginkeeping" value="loginkeeping" /> 
									<label for="loginkeeping">记住登录状态</label>
								</p>-->
                                <p class="login button"> 
                                    <input type="submit" value="{$Think.lang.LOGIN}" id="submit" style="width: 30%;"/> 
								</p>
                            </form>
                        </div>

                        
                    </div>
                </div>  
            </section>
        </div>
        <script>
            $(document).ready(function(){
                var timer;
                $(".changeVerify").click(function(){
                    clearTimeout(timer);
                    $('#verify').attr('src','{:U("Admin/User/verify")}'+'?r='+Math.random());
                });
                
                $("#lgin").submit(function(){
                    login();
                    return false;
                });
                
                $("#code").keypress(function(){
                    $(this).val($(this).val().toUpperCase());
                })
                
                $("#code").blur(function(){
                    $(this).val($(this).val().toUpperCase());
                })
                
            });
            
            function login(){
                var username = $("#username").val();
                var pass = $("#password").val();
                var code = $("#code").val();
                if(username==""){
                    $('<span id="resultMsg" />').addClass("ajaxerror").html("用户名不能为空！").appendTo('.login').fadeOut(2000);
                    $("#username").focus();
                    return false;
                }
                if(pass==""){
                    $('<span id="resultMsg" />').addClass("ajaxerror").html("密码不能为空！").appendTo('.login').fadeOut(2000);
                    $("#password").focus();
                    return false;
                }
                if(code==""){
                    $('<span id="resultMsg" />').addClass("ajaxerror").html("验证码不能为空！").appendTo('.login').fadeOut(2000);
                    $("#code").focus();
                    return false;
                }
                var url = "{:U('Admin/User/doLogin')}";
                var data = $("#lgin").serialize();
                $("#submit").disabled = true;
                $("#submit").val('正在登录...');
                $.ajax({
                    url:url,
                    cache:false,
                    dataType:"json",
                    data:data,
                    type:"POST",
                    error:function(){
                        $("#submit").val('登录');
                        $('<span id="resultMsg" />').addClass("ajaxerror").html("{$Think.lang.AJAXERROR}").appendTo('.login').fadeOut(3000); 
                    },
                    success:function(msgObj){
                        if(msgObj.status == '1'){
                            $("#submit").val('登录成功');
                            $("#submit").disabled = false;
                            $('<span id="resultMsg" />').removeClass("ajaxerror").css({"color":"#669533","background":"url('__PUBLIC__/Admin/images/loading.gif') no-repeat 1px"}).html(msgObj.info+" 正在进入系统！.......").appendTo('.login');
                            setTimeout(function(){
                                location.href = $("#doUrl").attr("callback_url");
                            },1500);
                        }else{
                            $("#submit").val('登录');
                            $('<span id="resultMsg" />').addClass("ajaxerror").html(msgObj.info).appendTo('.login').fadeOut(3000); 
                            fleshVerify();
                        }
                    }
                });
            }
            
            function fleshVerify(){
                var time = new Date().getTime();
                $("#verify").attr('src',"{:U('Admin/User/verify')}?r="+time);
            }
            
            
        </script>
    </body>
</html>